// https://leetcode.cn/problems/count-of-substrings-containing-every-vowel-and-k-consonants-i/description/?envType=daily-question&envId=2025-03-12

package main

var o map[byte]bool

func least(word string, k int) (ans int64) {
	rec := make(map[byte]int)
	nolen := 0
	l := 0
	for _, v := range word {
		if _, ok := o[byte(v)]; ok {
			rec[byte(v)]++
		} else {
			nolen++
		}
		for ; len(rec) == 5 && nolen >= k; l++ {
			if _, ok := o[word[l]]; ok {
				rec[word[l]]--
				if rec[word[l]] == 0 {
					delete(rec, word[l])
				}
			} else {
				nolen--
			}
		}
		ans += int64(l)		
	}
	return ans
}

func countOfSubstrings(word string, k int) int64 {
	o = make(map[byte]bool)
	o['a'] = true
	o['e'] = true
	o['i'] = true
	o['o'] = true
	o['u'] = true
	return least(word, k) - least(word, k + 1)
}

func main() {
	word := "ieaouqqieaouqq"
	k := 1
	print(countOfSubstrings(word, k))
}
